package org.ysu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.ysu.entity.Clue;
import org.ysu.entity.Role;
import org.ysu.entity.SysResource;
import org.ysu.service.ClueService;
import org.ysu.vo.ResultVO;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 线索表 前端控制器
 * </p>
 *
 * @author CaoYuJia
 * @since 2024-08-20
 */
@RestController
@RequestMapping("/clue")
@Api(tags = "线索接口")
public class ClueController {
    @Resource
    ClueService clueService;
    @GetMapping("/list")
    ResultVO<IPage<Clue>> list(Integer pageNo, Integer pageSize,Long rId){
        return ResultVO.success(clueService.list(pageNo,pageSize,rId));
    }
    @GetMapping("/recordList")
    ResultVO<IPage<Clue>> recordList(Integer pageNo, Integer pageSize,Long verifierId){
        return ResultVO.success(clueService.recordList(pageNo,pageSize,verifierId));
    }
    @PostMapping("/add")
    ResultVO<Boolean> add(Long ccId,Long fid,String province,String city,String county,String township,String village,Boolean riskMan,Boolean riskSubstance,Boolean riskNature,Boolean riskFinance,Boolean riskSocial,Integer riskLevel,String riskRemark,Boolean verify,Long rid) {
        return ResultVO.success(clueService.add(ccId, fid, province, city, county, township, village,riskMan,riskSubstance,riskNature,riskFinance,riskSocial,riskLevel,riskRemark,verify,rid), "添加线索成功");
    }
    @PostMapping("/update")
    ResultVO<Boolean>update(Long id,Long ccId,Long fid,String province,String city,String county,String township,String village,Boolean riskMan,Boolean riskSubstance,Boolean riskNature,Boolean riskFinance,Boolean riskSocial,Integer riskLevel,String riskRemark,Boolean verify,Long rid){
        return ResultVO.success(clueService.update(id,ccId,fid, province, city, county, township, village,riskMan,riskSubstance,riskNature,riskFinance,riskSocial,riskLevel,riskRemark,verify,rid),"修改线索成功");
    }
    @PostMapping("/del")
    ResultVO<Boolean>del(Long id,Boolean valid){
        return ResultVO.success(clueService.del(id,valid), valid ? "启用线索成功" : "删除线索成功");
    }
    @PostMapping("/verify")
    ResultVO<Boolean>verify(Long id,Boolean verify,Boolean valid){
        return ResultVO.success(clueService.verify(id,verify,valid), verify ? "核实成功" : "未核实");
    }
   @GetMapping("/getById")
   ResultVO<Clue>getById(Long id){
        return ResultVO.success(clueService.getById(id));
   }
    @GetMapping("/check")
    ResultVO<Boolean> check(Long id, Long fId) {
        return ResultVO.success(clueService.check(id, fId));
    }
}
